package de.mhu.mandalaui.bind;

import java.io.PrintWriter;

import de.mhu.mandalaui.actions.DataSourceAction;
import de.mhu.mandalaui.attributes.ArrayAttribute;

public class StaticDataSource extends DataSourceAction {

	private ArrayAttribute target;
	
	@Override
	public void renderFunctionImplementation(PrintWriter out) {
		out.println("function(data) {");
		if (target != null) {
			target.renderRemoveAll(out);
			for (DataRow row : getData(null)) {
				target.renderAppendData(out,row);
			}
		} else
			out.println("// no target set");
		out.println("}");
	}

	public ArrayAttribute getTarget() {
		return target;
	}

	public void setTarget(ArrayAttribute target) {
		this.target = target;
	}

}
